<?php

class Utils {
	public static function get($id, $default){
		if(isset($_SESSION[$id])) {
			return $_SESSION[$id];
		} else if (isset($_REQUEST[$id])){
			return $_REQUEST[$id];
		}
		return $default;
	}
	
	public static function params(){
		$ret = array();
		foreach($_REQUEST as $k => $v) {
			$ret[$k] = $v;
		}
		foreach($_SESSION as $k => $v) {
			$ret[$k] = $v;
		}
		return $ret;
	}

	public static function redirect($url) {
		header( 'Location: '.$url );
		exit(0);
	}
	
	public static function createClass($class_name) {
		$clsFile = "c:/wamp/www/gm/game/".$class_name.".class.inc";
		if(file_exists($clsFile)) return;

		$fh = fopen($clsFile, 'w') or die("can't open file");
		$cls_body = <<<CLS
<?php

class $class_name extends Obj {
	public function $class_name() { 
		parent::__construct();
	}
}

?\>
CLS;
		fwrite($fh, $cls_body);
		fclose($fh);
	}

}

?>